#ifndef CTRL_CHANNEL_H_
#define CTRL_CHANNEL_H_

#include <stdlib.h>
#include "logger.h"
#include "link.h"

enum {
	PASV,
	PASV_ACK, /* 227 */
	PORT,
	PORT_ACK, /* 200 */
	RETR,
	STOR,
	OPEN_DATA, /* 150 */
	ERR_OPEN_DATA, /* 425 */
	ERR_DATA_CLOSED, /* 426 */
	ERR_NO_ACTION, /* 550 */
	DATA_FIN, /* 226 */
	SYNTAX_ERROR /* 501 */
};

enum {
	CTRL_PARSE_ERROR = -2, /* got bad response from remote host */
	CTRL_ERROR = -1, /* generic/unknown/fatal error */
	CTRL_SUCCESS = 0
};

typedef struct ctrl_message_t {
	int ctrl;
	int port;
	char filename[FILENAME_MAX];
} ctrl_message;

int ctrl_send_receive(link_t* link, ctrl_message* msg, ctrl_message* reply);

#endif /* CTRL_CHANNEL_H_ */
